var t = require("../../../@babel/runtime/helpers/interopRequireDefault").default,
  e = require("../../../utils/http.js"),
  a = t(require("../../../utils/util")),
  n = new e.HTTP;
let {
  addQdinfo,
  addLxrqd,
  editQdinfo,
  editLxrqd
} = require("../../../api/attract/qd_content")
Page({
  data: {
    selectArray: [{
      id: 1,
      text: "个人级"
    }, {
      id: 2,
      text: "项目部门级"
    }, {
      id: 3,
      text: "公司级"
    }],
    nowText: "请选择",
    purpose: [],
    sort: [],
    nowTexta: "请选择",
    sign: [{
      id: 1,
      text: "是"
    }, {
      id: 2,
      text: "否"
    }],
    nowTextb: "否",
    yixiangtype: 2,
    time: a.default.formatTime(new Date)
  },
  selectEvent: function (t) {
    this.setData({
      sortType: t.detail.selectedID,
      nowText: t.detail.nowText
    })
  },
  selectEvent2: function (t) {
    this.setData({
      sortTypes: t.detail.selectedID,
      nowTexta: t.detail.nowText
    })
  },
  selectEvent3: function (t) {
    this.setData({
      yixiangtype: t.detail.selectedID,
      nowTextb: t.detail.nowText
    })
  },
  selectEvent7: function (t) {
    this.setData({
      sections: t.detail.selectedID,
      nowTextf: t.detail.nowText
    })
  },
  formSubmits: function (t) {
    var e = this,
      o = t.detail.value;
    wx.showModal({
      title: "提示",
      content: "请核对数据是否准确",
      success: function (t) {
        if (t.confirm)
          if ("请选择" != e.data.nowText && o.khjc && o.iphonenum && o.hangye && "请选择" != e.data.nowTexta) {
            var i = "qd" + e.data.time.substring(2, 4).toString() + e.data.time.substring(5, 7).toString() + e.data.time.substring(8, 10).toString() + (e.data.time.substring(14, 16) + 1).toString();
            null == e.data.nowTextb && e.setData({
                nowTextb: "否"
              }),
              null == e.data.nowTextf && e.setData({
                nowTextf: e.data.name[1]
              }),
              addQdinfo({
                qymc: o.khjc,
                bm: e.data.nowTextf,
                qdjb: e.data.nowText,
                whry: o.lxr,
                qdfl: e.data.nowTexta,
                qdqy: e.data.nowTextb,
                lxr: o.iphonenum,
                lxfs: o.hangye,
                tname: e.data.name[0],

              }).then((function (t) {
                addLxrqd({
                    khbh: t.qdbh,
                    qymc: o.khjc,
                    lxr: o.iphonenum,
                    lxfs: o.hangye,
                    tname: e.data.name[1]
                  }).then((function (t) {})),
                  n.request({
                    url: "https://www.qlsyyun.com:3030/channel/stjd",
                    header: {
                      "Content-Type": "application/x-www-form-urlencoded"
                    },
                    method: "POST",
                    data: {
                      khbh: t.qdbh,
                      qymc: o.khjc,
                      bm: e.data.nowTextf,
                      tname: e.data.name[1]
                    }
                  }).then((function (t) {})),
                  n.request({
                    url: "https://www.qlsyyun.com:3030/channel/stmx",
                    header: {
                      "Content-Type": "application/x-www-form-urlencoded"
                    },
                    method: "POST",
                    data: {
                      khbh: t.qdbh,
                      qymc: o.khjc,
                      bm: e.data.nowTextf,
                      tname: e.data.name[1],
                      qdjb: e.data.nowText,
                      time: a.default.formatTime(new Date).substring(0, 10)
                    }
                  }).then((function (t) {})),
                  n.request({
                    url: "https://www.qlsyyun.com:3030/clock/qudao",
                    header: {
                      "Content-Type": "application/x-www-form-urlencoded"
                    },
                    method: "POST",
                    data: {
                      qymc: o.khjc,
                      bm: e.data.nowTextf,
                      zsy: e.data.name[0]
                    }
                  }).then((function (t) {})),
                  wx.showToast({
                    title: "添加成功",
                    icon: "success",
                    duration: 1e3,
                    success: function () {
                      setTimeout((function () {
                        wx.navigateBack({
                          delta: 1
                        })
                      }), 1e3)
                    }
                  })
              }))
          } else
            wx.showToast({
              title: "请检查是否有必填项未填",
              icon: "none",
              duration: 1e3
            })
      }
    })
  },
  quxiao: function () {
    wx.navigateBack({
      delta: 1
    })
  },
  onLoad: function (detail) { 
    var t = this,
      e = wx.getStorageSync("user");
      t.setData({
        name:e
      })
    n.request({
        url: "https://www.qlsyyun.com:3030/channel/add",
        data: {
          arr: 1
        }
      }).then((function (e) {
        t.setData({
          purpose: e.data
        })
      })),
      n.request({
        url: "https://www.qlsyyun.com:3030/channel/add",
        data: {
          arr: 2
        }
      }).then((function (e) {
        t.setData({
          sort: e.data
        })
      }))

  }
});